package com.freedo.demo;

import org.apache.catalina.filters.RemoteIpFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.freedo.demo.filter.CrosFilter;
import com.freedo.demo.filter.LogFilter;


@Configuration
public class WebConfiguration {

	@Bean
	public RemoteIpFilter remoteIpFilter() {
		return new RemoteIpFilter();
	}
	
	@Bean
	public FilterRegistrationBean<LogFilter> logFilterRegistration(){
		FilterRegistrationBean<LogFilter> registration = new FilterRegistrationBean<LogFilter>();
		registration.setFilter(new LogFilter());
		registration.addUrlPatterns("/*");
		registration.addInitParameter("paramName", "paramValue");
		registration.setName("LogFilter");
		registration.setOrder(1);
		return registration;
	}
	

	@Bean
	public FilterRegistrationBean<CrosFilter> crosFilterRegistration(){
		FilterRegistrationBean<CrosFilter> registration = new FilterRegistrationBean<CrosFilter>();
		registration.setFilter(new CrosFilter());
		registration.addUrlPatterns("/*");
		registration.addInitParameter("paramName", "paramValue");
		registration.setName("CrosFilter");
		registration.setOrder(1);
		return registration;
	}

	
}
